import React, { Component } from 'react';


class Chan extends Component {

    constructor(props) {
        super(props);
    }
    //查所有随笔
	topicschaall = () => {
		//console.log('topicschaall');
		fetch('http://62.234.30.197:8088/topics/chaall', {
			method: 'post',
			headers: {
			    "Access-Control-Allow-Origin":"*",
			    'content-type': 'application/json'
			},
			mode: 'cors'
		})
		.then(res=>res.json())
		.then(res=> {
			//console.log(res)
			var _html = ``;
			res.forEach( (item) => {
				_html += `<span>txt:  ${item.txt}</span><br />`;
				_html += `<span>userid:  ${item.userid}</span><br />`;
				_html += `<span>pic:  ${item.pic}</span><br />`;
				_html += `<span>topicsid:  ${item.topicsid}</span><br /><br /><br />`;
			} );
			//$("#container").html( _html );
			document.getElementById('container').innerHTML = _html;
		})
    }
    
    //增加新的随笔
	topicszeng = () => {
		//console.log('topicszeng');
		fetch('http://62.234.30.197:8088/topics/zeng', {
			method: 'post',
			body: JSON.stringify({'txt':'这是新增加的随笔内容txt','pic':'zheshi pic','userid':`${this.state.userid}`}),
			headers: {
			    "Access-Control-Allow-Origin":"*",
			    'content-type': 'application/json'
			},
			mode: 'cors'
		})
		.then(res=>res.json())
		.then(res=> {
			//console.log(res)
		})
	}
    render(props) {
        return (
            <div >
                
            </div>
        )
    }}

export default Chuan